<template>
	<view :style="width='100%'   ">
		
		<newNavBar></newNavBar>
		
		<uni-section style="box-shadow:0px 0px 4px 1px #d0d0d0; margin: 10px; border-radius: 6px;"
			:typeColor="mainColor" type="line" titleColor="#000" titleFontSize="17px" v-for="(menu,index) in menuList"
			:title="menu.title" :index="index" :key="index">
			<!-- <uni-card  margin="0px 10px" padding="0px"> -->
			<view style="margin:0px 10px 10px 10px;border-radius: 6px;">
				<uni-grid :column="menu.menuCount" :highlight="true" :show-border="false"
					@change="change(index,$event)">
					<uni-grid-item v-for="(item,index) in menu.list" :index="index" :key="index">
						<view class="grid-item-box" style="background-color: #fff;">
							<view
								style="padding-bottom: 0px;display: flex; justify-content: center;align-items: center;"
								:style="{'margin-bottom': '3px','border-radius': '6px', 'width': '45px', 'height': '45px','background-image': 'linear-gradient('+item.imageColor+')' }">
								<uni-icons customPrefix="my-iconfont" :type="item.icon"
									:size="(item.size!=undefined &&item.size!=''?item.size:35)" :color="item.color" />
							</view>
							<view style="display: grid;">
								<text class="text"
									style="font-family: 'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif; font-weight: 500;  height: 16px;font-size: 14px; overflow: hidden; text-overflow: ellipsis;">{{item.name}}</text>
							</view>
						</view>
					</uni-grid-item>
				</uni-grid>
			</view>
			<!-- </uni-card> -->
		</uni-section>
		
		<view>
			
		</view>
		<newTabBar ref="tabBar" :tabList="tabList"></newTabBar>
	</View>
</template>

<script>
	
	import * as SystemJs from '@/common/system.js'
	import tabBar from '../unit/tabBar.vue'
	import * as configJs from '../../common/config.js'
	export default {
		//声明引用的vue公用组件
		components: {
			tabBar
		},
		data() {
			return {
				mainColor: '',
				title: '标题栏',
				menuList: [],
				tabList: [],
				treeData: [{
						name: '1',
						key: '1',
						children: [{
								name: '1-1',
								key: '1-1',
								children: [{
									name: '1-11',
									key: '1-11',
									children: []
								}]
							},
							{
								name: '1-2',
								key: '1-2',
								children: []
							}
						]
					},
					{
						name: '2',
						key: '2',
						children: [{
								name: '2-1',
								key: '2-1',
								children: []
							},
							{
								name: '2-2',
								key: '2-2',
								children: []
							}
						]
					}
				],
				defaultCheckedList: ['1-2'],
				badgeNumber: '0'
			}
		},
		methods: {
			loadData() {
				var obj = {};
				var acount = uni.getStorageSync('account');
				obj.baseCode = acount;
				obj.userCode = configJs.getBaseInfo.getUserInfo().userCode;
				SystemJs.httpUnit.requestCryptoPost({
					url: 'App/GetMenuList',
					data: obj
				}).then((res) => {
					if (res.Result) {
						var data = res.Data;
						this.menuList = data.parentList;
					 console.log(JSON.stringify(res.Data))
					} else {
						SystemJs.httpUnit.uniToast(JSON.stringify(res.Message))
					}
				}).catch((err) => {
					SystemJs.httpUnit.uniToast(JSON.stringify(err))
				})
			},
			checkSelected(e) {
				console.log(e)
			},
			nodeClick(e) {
				console.log(e)
			},
			//点击卡片中某个模块的方法
			change(parentIndex, e) {
				var {
					index
				} = e.detail
				var parentMenu = this.menuList[parentIndex]
				var pageItem = parentMenu.list[index]
				var pathUrl = pageItem.pathUrl
				getApp().globalData.PageItem.code = pageItem.code
				getApp().globalData.PageItem.name = pageItem.name
				// systemJs.showTitleBar(pageItem.name, true)
				var url = pathUrl + "?pageCode=" + pageItem.code + "&pageName=" + pageItem.name;
				if (pageItem.pageType) {
					url = url + "&pageType=" + pageItem.pageType;
				}
				if (pageItem.cParentMenu) {
					url = url + "&parentMenu=" + pageItem.cParentMenu;
				}
				uni.navigateTo({
					url: url
				})
			}
		},
		onShow() {
			this.loadData();
		},
		//初始化加载方法
		onLoad() {

			this.mainColor = configJs.baseColor.mainTitleColor;
			SystemJs.systemJs.showTitleBar('工作台', false)
			this.tabList = configJs.configData.tabList;
			

		}
	}
</script>

<style>
	.swiper {
		height: 0px;
	}

	.grid-dynamic-box {
		margin-bottom: 15px;
	}

	.grid-item-box {
		flex: 1;
		/* // position: relative; */
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: column;
		align-items: center;
		justify-content: center;
		/* padding: 15px 0; */
	}

	.grid-item-box-row {
		flex: 1;
		/* // position: relative; */
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: row;
		align-items: center;
		justify-content: center;
		padding: 15px 0;
	}
</style>